package com.exception;

/***
 * @ClassName: ExceptionTest
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 14:46 2022/1/27
 * @version : V1.0
 */
public class ExceptionTest {
    public static void main(String[] args) {
        int a = 1;
        int b = 0;


        //try监控区域
        try {
            if(b == 0){
                throw new Exception("除数为0错误");
            }
            System.out.println(a / b);
        }
        //捕获异常
        catch (Exception e) {
            System.out.println("Exception错误" + e.toString());
        }
        //多层捕获异常
        catch (Throwable e) {
            System.out.println("Throwable错误" + e.toString());
        }
        //必然执行的操作，一般关闭流的操作
        finally {
            System.out.println("必然执行的代码");
        }
    }
}
